package com.example.demo_one.kotlin

import com.google.android.material.color.utilities.Score

fun main() {
//    使用主构造函数创建对象
    val man = Person5("张三")
    man.show()

    val woman = Person5("李四")
    woman.show()

//    使用次构造函数创建对象
    val man2 = Person5("赵六", 18880)
    man2.intro()

//    使用次构造函数创建对象
    val man3 = Person5("王五", 180, 180)
    man3.showScore()
}

// 隐式主构造函数
class Person5(var name: String) {
    var age: Int = 0
    var Score: Int = 0

    //    次构造函数1
    constructor(name: String, age: Int) : this(name) {
        this.age = age
    }

    //    次构造函数2
    constructor(name: String, age: Int, Score: Int) : this(name) {
        this.age = age
        this.Score = Score
    }

    fun show() {
        println("姓名:$name")
    }

    fun intro() {
        println("姓名:$name , 年龄:$age")
    }

    fun showScore() {
        println("姓名:$name,年龄:$age,成绩:$Score")
    }
}